module.exports = {
  type: 'list',
  async fetch({ args, page }) {
    let res
    let LS //= 'animation'
    if (this.nextPage == null) {    
    
    LS = args.keyword

    if (LS != null) {
      if (!$storage.has('搜索库')) {
        $storage.put('搜索库', 'serch_18av')
        $ui.toast('自动设置搜索库为;\n' + $storage.get('搜索库'))
      }
      $ui.toast('在库' + $storage.get('搜索库') + '里搜索\n' + LS)
      this.title = $storage.get('搜索库') + '里搜  ' + LS
      //修改标题
      
      
      this.nextPage =  'https://' +          $prefs.get('baseURL') +          '/' +          $storage.get('搜索库') +          '/' +          encodeURI(LS) +          '_1.htm'
    } else {
      this.nextPage=args.httpDR
    }
    }          
      
    
      
///\\\\\||||||||||\\\\\\\\\
    
    if (this.nextPage == this.SYY) {
      this.nextPage = null
      //$ui.toast('到底了')
      return {
        items: [{ title: '到底了' }],

        nextPage: this.nextPage
      }
    } else {
      this.SYY = this.nextPage
      res = await $http.get(this.nextPage, header_asb)

      //let res = await $http.get(`https://maa1804.com/serch_mvsort/%E8%99%95%E7%94%B7_${page || 1}.htm`,header_asb)

///\\\\\||||||||||\\\\\\\\\

    //eval("DSF_zujian."+'rr')(item.title, lsls)
    //字符串转可执行代码eval("这里面的是字符串")
    let sdf = 0
    this.title = args.title + '    ' + String(args.iqqDR++)
    ////////////////////
    

    ///\\\\\||||||||||\\\\\\\\\

      let ixa = res.data

      ///////////////////////////////////////
      if (ixa.indexOf('class="aRF_Scg"') == -1) {
        this.finish()
        $router.to(
          $route('biaoge', { ixa: ixa, title: args.title, iqqDR: args.iqqDR })
        )
      }

      let uutt = []

      let eee = "class='pageback'><a href='(.+?)'>下一頁 >"

      let http_XYY = ixa.match(eee)
      let XYY_title = '继续随机'

      //是否有下一页
      if (http_XYY != null) {
        this.nextPage = encodeURI('https:' + http_XYY[1])
        //XYY_title = '下一页'
      }

      let nnaa = new RegExp(
        '<a class="aRF".{1,37}?href="(.{5,65}?)".{1,37}?class="aRF_Scg".{1,37}?src="(.{1,65}?)".{1,37}?alt="(.{1,154}?)"',
        'g'
      )

      let ixaqq = ixa.match(
        '<a class="aRF".{6,140}?class="aRF_Scg".{4,150}?alt="(.|\n|\r)+<a class="aRF".{6,140}?class="aRF_Scg".{4,150}?alt=".{3,400}?</a>'
      )
      if (ixaqq != null) {
        ixa = ixaqq
      }

      let items = []

      let items_aa = {
        onClick: () => {
          //$ui.toast(JSON.stringify(   ))

          this.finish()
          $router.to(
            $route('LB_liebiao', {
              title: args.title,
              httpDR: args.httpDR,
              iqqDR: args.iqqDR
            })
          )
        },
        title: XYY_title
      }

      items.push(items_aa)

      var liebiao_onClick = require('.//JS/liebiao_onClick.js')
      //调用当前目录的bb.js
      //循环获取和显示新的内容
      while ((uutt = nnaa.exec(ixa)) != null) {
        let LS
        //是否为xp1网页
        if (uutt[1].indexOf('/xp1/') != -1) {
          LS = false
        } else {
          LS = true
        }
        //lsls和BFQ是为onClick准备的
        let lsls = uutt
        let BFQ = LS

        items.push({
          title: uutt[3],

          //列表样式
          style: 'article',
          //大小，最多12
          spanCount: 12,
          //image: uutt[2],
          onClick: item => {
            //是否为xp1网页
            if (BFQ) {
              liebiao_onClick.ee(item.title, lsls)
            } else {
              liebiao_onClick.rr(item.title, lsls)
            }
          }
        })
      }
      XYY = null
      items.push(items_aa)
      return {
        items: items,
        nextPage: this.nextPage

        //nextPage : (page || 1)  + 1
        //nextPage: http_XYY != null ? (page || 1)  + 1 : null
      }
    }
    ///\\\\\||||||||||\\\\\\\\\
    //return   qq(titleT, XYY_title, nnaa,ixa,this.finish)
  }
}
